<template>
  <div class="container">
    <el-dialog
      title="预览文章"
      :visible.sync="dialogVisible"
      width="50%"
      v-model="formData"
    >
      <h3>{{ formData.title }}</h3>
      <span>
        {{ formData.createTime | parseTimeByString }}
      </span>

      <i class="el-icon-view"></i>
      <span class="userSpan">{{ formData.visits }}</span>
      <span>{{ formData.username }}</span>
      <div v-html="formData.articleBody" class="articleBody"></div>
    </el-dialog>
  </div>
</template>

<script>
import { parseTimeByString } from '../../filters/index'

import { list, detail } from '../../api/hmmm/articles'

export default {
  props: {
    formData: {
      type: [Array, Object],
      require: true,
    },
  },
  data() {
    return {
      dialogVisible: false,
      previewForm: {
        title: '',
        createTime: '',
        username: '',
        visits: '',
      },
      previewItems: [],
      formrules: {
        page: 1,
        pagesize: 10,
      },
    }
  },
  methods: {
    async getlist(data) {
      const { data: res } = await list(this.formrules)
      console.log(res)
      this.previewItems = res.items
    },
  },
  created() {
    this.getlist()
  },
}
</script>

<style>
.articleBody {
  background-color: #f5f5f5;
  border-top: 2px dashed #e1e1e1;
  margin-top: 15px;
}
.userSpan {
  margin: 0 10px;
}
</style>
